{% extends "layout-settings.html" %}
{% set active_page = "settings" %}
{% set active_settings = "alerts" %}
{% set help_page = ["https://kizniche.github.io/Mycodo/Configuration-Settings/#alert-settings", dict_translation['settings']['title'] + ': ' + dict_translation['alert']['title']] %}

{% block title %} - {{dict_translation['settings']['title'] + ': ' + dict_translation['alert']['title']}}{% endblock %}

{% block settings %}
  <!-- Route: /settings/alerts -->
  <div class="container">
    <h3 style="text-align: right; padding-bottom: 1.3em;"><a href="https://kizniche.github.io/Mycodo/Configuration-Settings/#alert-settings" target="_blank"><span style="font-size: 16px" class="fas fa-question-circle"></span></a> {{_('Alerts Settings')}}</h3>

    <form class="form-horizontal" method="post" action="/settings/alerts">
      <input type="hidden" name="form-name" value="EmailAlert">
      {{form_email_alert.hidden_tag()}}
      <div class="form-group">
        If a port is not specified, the default port for SSL (465), TLS (587), or unencrypted (25) will be used. If you require a non-standard port, enter it in the port field.
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_host.label(class_='control-label')}}
        <div>
          {{form_email_alert.smtp_host(class_='form-control', value=smtp.host)}}
        </div>
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_port.label(class_='control-label')}}
        <div>
          {{form_email_alert.smtp_port(class_='form-control',type="number", value=smtp.port,**{'title':_('Leave blank to use default port for protocol')})}}
        </div>
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_protocol.label(class_='control-label')}}
        <div>
          <select class="form-control form-tooltip form-dropdown" id="smtp_protocol" name="smtp_protocol" data-placement="top" title="{{_("Email protocol to send with")}}">
            <option value="ssl"{%- if smtp.protocol == 'ssl' %} selected{%- endif -%}>SSL</option>
            <option value="tls"{%- if smtp.protocol == 'tls' %} selected{%- endif -%}>TLS</option>
            <option value="unencrypted"{%- if smtp.protocol == 'unencrypted' %} selected{%- endif -%}>Unencrypted</option>
            <option value="unencrypted_no_login"{%- if smtp.protocol == 'unencrypted' %} selected{%- endif -%}>Unencrypted (no login)</option>
          </select>
        </div>
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_user.label(class_='control-label')}}
        <div>
          {{form_email_alert.smtp_user(class_='form-control', value=smtp.user,**{'title':_('Usually your full email address')})}}
        </div>
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_password.label(class_='control-label')}}
        <div>
          {{form_email_alert.smtp_password(class_='form-control',**{'title':_('Only enter a password here if you wish to change it')})}}
        </div>
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_from_email.label(class_='control-label')}}
        <div>
          {{form_email_alert.smtp_from_email(class_='form-control', value=smtp.email_from)}}
        </div>
      </div>
      <div class="form-group">
        {{form_email_alert.smtp_hourly_max.label(class_='control-label')}}
        <div>
          {{form_email_alert.smtp_hourly_max(class_='form-control',type="number", value=smtp.hourly_max, **{'title':_('Maximum number of alerts that can be emailed per hour.')})}}
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-offset-4 col-sm-8">
          {{form_email_alert.save(class_='btn btn-primary')}}
        </div>
      </div>

      <div class="row" style="padding: 1.5em 0 1em 0">
        <div class="col">
          {{form_email_alert.send_test_to_email(class_='form-control')}}
        </div>
        <div class="col">
          {{form_email_alert.send_test(class_='btn btn-primary')}}
        </div>
      </div>

    </form>

  </div>

{% endblock %}
